﻿<?php
if (!isset($_GET['id'])) {
    echo "Системная ошибка!";
    exit;
} else {
    $id=$_GET['id'];
}
//include 'func/f_ping.php';
////////////////////////////////////

include 'bd.php';
$result_select_id = mysql_query("SELECT * FROM abon where id='$id'",$db); 
$myrow_ip = mysql_fetch_array($result_select_id);
$host = $myrow_ip["ip"];
//////////////////////////

//$proverka = Ping($host);

/*if ($proverka === FALSE){
    echo "<a href='javascript:snmp_get(".$host.");'><img src='img/refresh.svg' width='20px' style='margin:0px 7px -4px 0px;' slt='RePing'   /></a>";
    echo "<font color=#FF0033><strong>Нет доступа </strong></font>";
    exit;
}*/
//////////////////////////////////////
$group = "public";

echo "<table> <tr> <td>";

/////////////////////  Name
echo "<div style='border:1px solid #ccc; width:100px; float:left; padding:3px; margin:3px;'>";
echo "<h4 style='margin:3px; padding:0px;'>Интерфейс</h4>";
$name = snmpwalk($host, $group, ".1.3.6.1.2.1.2.2.1.2");

for ($i=0;$i<count($name);$i++){
    $str = $name[$i];
    $chars = preg_split('/["]+/', $str, -1, PREG_SPLIT_OFFSET_CAPTURE);
/////////// 
   echo $chars[1][0]."<br>";
}
echo "</div>";

/////////////////////   Admin Status
echo "<div style='border:1px solid #ccc; width:150px; float:left; padding:3px; margin:3px;'>";

echo "<h4 style='margin:3px; padding:0px;'>На устройстве</h4>";

$AdmSt = snmpwalk($host, $group, ".1.3.6.1.2.1.2.2.1.7");

for ($i=0;$i<count($AdmSt);$i++){
    $str = $AdmSt[$i];
    $chars = preg_split('/[:]+/', $str, -1, PREG_SPLIT_OFFSET_CAPTURE);
    /////////
    $St = $chars[1][0];
    if ($St == 1) {
        echo "<font color='green'>Включено</font> | <font color='red'>Выключить</font>";
    }
    else {
        echo "<font color='red'>Выключено</font> | <font color='green'>Включить</font>";
    }
    echo "<br>";
}

echo "</div>";


///////////////////////////  Oparation Ststus
echo "<div style='border:1px solid #ccc; width:100px; float:left; padding:3px; margin:3px;'>";

echo "<h4 style='margin:3px; padding:0px;'>У абонента</h4>";

$OpSt = snmpwalk($host, $group, ".1.3.6.1.2.1.2.2.1.8");

for ($i=0;$i<count($OpSt);$i++){
    $str = $OpSt[$i];
    $chars = preg_split('/[:]+/', $str, -1, PREG_SPLIT_OFFSET_CAPTURE);
    /////////
    $St = $chars[1][0];
    if ($St == 1) {
        echo "<font color='green'>Включено</font>";
    }
    else {
        echo "<font color='red'>Выключено</font>";
    }
    echo "<br>";
}

echo "</div>";
echo "</td> </tr>";
////////////////////Новая строка
echo "<tr> <td>";
/////////////////Блок вывода времени работы устройства
echo "<div style='border:1px solid #ccc; width:338px; float:left; padding:3px; margin:3px;'>";

echo "<h4 style='margin:3px; padding:0px;'>Время работы</h4>";

$uptime = snmpget($host,$group,".1.3.6.1.2.1.1.3.0");
    $str = $uptime;
    $chars = preg_split('/[)]+/', $str, -1, PREG_SPLIT_OFFSET_CAPTURE);
    /////////
    echo $chars[1][0];
    
     $conn = ssh2_connect('10.11.20.200', 22);
     echo $conn;
     ssh2_auth_password($connection, 'ubnt', 'ubnt');
     $stream = ssh2_exec($connection, 'ls');
     echo $stream;


echo "</div>";
echo "</td> </tr>";

echo "</table>";


?>


